package com.mathpractise.model;

import com.mathpractise.model.enums.QuestionType;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * 题目实体类
 */
public class Question {
    
    /**
     * 题目ID
     */
    private String id;
    
    /**
     * 题目表达式，例如 "1+2"
     */
    private String expression;
    
    /**
     * 正确答案
     */
    private int correctAnswer;
    
    /**
     * 选项列表
     */
    private List<Integer> options;
    
    /**
     * 题目类型
     */
    private QuestionType questionType;
    
    public Question() {
        // 自动生成题目ID
        this.id = UUID.randomUUID().toString();
    }
    
    public Question(String id, String expression, int correctAnswer, List<Integer> options, QuestionType questionType) {
        this.id = id;
        this.expression = expression;
        this.correctAnswer = correctAnswer;
        this.options = options;
        this.questionType = questionType;
    }
    
    // Getters and setters
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getExpression() {
        return expression;
    }
    
    public void setExpression(String expression) {
        this.expression = expression;
    }
    
    public int getCorrectAnswer() {
        return correctAnswer;
    }
    
    public void setCorrectAnswer(int correctAnswer) {
        this.correctAnswer = correctAnswer;
    }
    
    public List<Integer> getOptions() {
        return options;
    }

    public List<String> getOptionStringList() {
        if (options == null) {
            return new ArrayList<>();
        }
        return options.stream().map(String::valueOf).toList();
    }
    
    public void setOptions(List<Integer> options) {
        this.options = options;
    }
    
    public QuestionType getQuestionType() {
        return questionType;
    }
    
    public void setQuestionType(QuestionType questionType) {
        this.questionType = questionType;
    }
}